package cn.han.io;

import java.io.*;

public class TestOut {
    public static void main(String[] args) {
        method1();
//        method2();
    }

    private static void method2() {
        OutputStream os = null;
        try{
            os = new FileOutputStream("D:\\ready\\5.txt",true);
//            os = new FileOutputStream(new File("D:\\ready\\5.txt"));
            os.write(98);

        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method1() {
        Writer w =null;
        try{
            w = new BufferedWriter(new FileWriter("D:\\ready\\5.txt", true));
            w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("D:\\ready\\5.txt"))));
            w.write(97);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                w.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
